package org.stone.project;

import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Schedulers;

public class AsyncDemo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = Thread.currentThread();
        System.out.println("当前线程名称"+thread.getName());

        Flux<String> demo = Flux.just("demo")
                .map(e -> {
                    System.out.println("显示" + e);
                    Thread sonThread = Thread.currentThread();
                    System.out.println("当前线程名称" + sonThread.getName());
                    return e;
                })
                .flatMap(e->{
                    return Mono.fromCallable(()->{
                        Thread.sleep(5000);
                        System.out.println("睡醒执行");
                        Thread sonThread = Thread.currentThread();
                        System.out.println("当前线程名称" + sonThread.getName());
                        return e;
                    });
                })
                .map(e->{
                    System.out.println("okok");
                    return e;
                })
                .subscribeOn(Schedulers.parallel());

        demo.subscribe();





        Thread.currentThread().join();
    }
}
